<?php
defined('_JEXEC') or die('Direct Access to this location is not allowed.'); 
class Modprop_carrouselHelper
{
    function getItems($cantmostrar)
    {        
        $db = &JFactory::getDBO();     
        $query = 'SELECT p.*,c.name as nc, t.name as tn, '
				. ' CASE WHEN CHAR_LENGTH(p.alias) THEN CONCAT_WS(":", p.id, p.alias) ELSE p.id END as slug,'
				. ' CASE WHEN CHAR_LENGTH(c.alias) THEN CONCAT_WS(":", c.id, c.alias) ELSE c.id END as catslug,'
				. ' CASE WHEN CHAR_LENGTH(t.alias) THEN CONCAT_WS(":", t.id, t.alias) ELSE t.id END as typeslug'
                . ' FROM #__properties_products AS p '
				. ' LEFT JOIN #__properties_category AS c ON c.id = p.parent '
				. ' LEFT JOIN #__properties_type AS t ON t.id = p.type '
				. ' ORDER BY p.id DESC '
				. ' LIMIT '.$cantmostrar;				
        
        $db->setQuery($query);	
			$items = $db->loadObjectList();
       // $items = ($items = $db->loadObjectList())?$items:array(); 
		
        return $items;
    }  
	function NameCategory()

	{	
	$db 	=& JFactory::getDBO();	
	$query = 'SELECT * FROM #__properties_category WHERE published = 1 ORDER BY id';		
        $db->setQuery($query);        
		$Categories = $db->loadObjectList();

	foreach ($Categories as $row) :
	$Category[$row->id] = $row->name;
	endforeach; 
	
	return $Category;
	}

function NameType()
	{	
	$db 	=& JFactory::getDBO();	
	$query = 'SELECT * FROM #__properties_type WHERE published = 1 ORDER BY name';		
        $db->setQuery($query);        
		$Types = $db->loadObjectList();
		
	foreach ($Types as $row) :
	$Type[$row->id] = $row->name;
	endforeach; 
	
			
		return $Type;
	}
} 
?>